import fetch from '../config/fetch'
import { getStore } from '../config/mUtils'
var pageSize = 10;

/**
 * 获取菜单
 */
export const getMenu = () => fetch({
  url: '/menu/v1/all',
  method: "get",
  data: {}
});



// -------------------上传视频-------------------

/**
 * 获取所有类型列表
 */
export const getAllColumn = () => fetch({
  url: '/column/v1/owner',
  method: "get",
  data: {}
});

/**
 * 添加类型
 */
export const createColumn = (data) => fetch({
  url: '/column/v1',
  method: "post",
  data: data
});

/**
 * 删除类型
 */
export const deleteColumn = (id) => fetch({
  url: '/column/v1/' + id,
  method: "delete",
  data: {}
});

/**
 * 修改类型
 */
export const updateColumn = (id, data) => fetch({
  url: '/column/v1/' + id,
  method: "put",
  data: JSON.stringify(data)
});

/**
 * 根据分类id获取视频—分页
 */
export const getAllVideo = (pageNumber, categoryId) => fetch({
  url: '/video/v1/orgOwner',
  method: "get",
  data: { pageNumber: pageNumber, pageSize, columnId: categoryId }
});

/**
 * 删除某一个视频
 */
export const deleteVideo = (id) => fetch({
  url: '/video/v1/' + id,
  method: "delete",
  data: {}
});

/**
 * 修改某一个视频
 */
export const updateVideo = (id, data) => fetch({
  url: '/video/v1/' + id,
  method: "put",
  data: JSON.stringify(data)
});

/**
 * 获取单个视频信息
 */
export const getVideo = (id) => fetch({
  url: '/video/v1/' + id,
  method: "get",
  data: {}
});

/**
 * 上传视频
 * params: {
  "columnId": "string",
  "description": "string",
  "expireTime": 0,
  "networkResource": true,
  "title": "string",
  "videoCoverObjectId": "string",
  "videoCoverUrl": "string",
  "videoObjectId": "string",
  "videoUrl": "string"
}
 */
export const createVideo = (data) => fetch({
  url: '/video/v1',
  method: "post",
  data: data
});

// -------------------上传视频-------------------

// -------------------语言-------------------
/**
 * 获取所有语言列表
 */
export const getAllLanguage = () => fetch({
  url: '/language/v1/all',
  method: "get",
  data: {}
});

/**
 * 创建一种语言
 */
export const addLanguage = (data) => fetch({
  url: '/language/v1',
  method: "post",
  data: data
});

/**
 * 删除某一种语言
 */
export const removeLanguage = (id) => fetch({
  url: '/language/v1/' + id,
  method: "delete",
  data: {}
});

/**
 * 修改某一种语言
 */
export const updateLanguage = (id, data) => fetch({
  url: '/language/v1/' + id,
  method: "put",
  data: JSON.stringify(data)
});
// -------------------语言-------------------

// -----------------机构管理-------------------

/**
 * 获取所有机构
 */
export const getOrganization = (pageNumber, status) => fetch({
  url: '/organization/v1',
  method: "get",
  data: { pageNumber: pageNumber, status: status, pageSize },
});

/**
 * 获取所有机构
 */
export const getOrganizationById = (pageNumber, id) => fetch({
  url: '/organization/v1/confirmOrg',
  method: "get",
  data: { pageNumber: pageNumber, courseId: id, pageSize },
});

/**
 * 获取所有机构
 */
export const selectOrganization = (name) => fetch({
  url: '/organization/v1',
  method: "get",
  data: { infoName: name },
});

/**
 * 重置机构密码
 */
export const resetPassword = (id) => fetch({
  url: '/organization/v1/' + id + '/account/resetPassword',
  method: "put",
  data: {},
});

/**
 * 重置机构密码
 */
export const setOrgAccount = (id, freeAccountNumber) => fetch({
  url: '/organization/v1/' + id + '/addFreeAccount',
  method: "put",
  data: {freeAccountNumber: freeAccountNumber},
});

/**
 * 删除机构
 */
export const deleteOrg = (id) => fetch({
  url: '/organization/v1/' + id,
  method: "delete",
  data: {},
});

/**
 * 获取自己邀请组织中，某一个课程未签约的组织机构
 */
export const getInviteOrgAndNotContract = (courseId) => fetch({
  url: '/organization/v1/inviteOrgAndNotContract',
  method: "get",
  data: { courseId: courseId },
});
// -----------------机构管理-------------------

// -----------------合同管理-------------------
/**
 * 创建一份合同
 * params: {
  "conConfirmerId": 0,  // 被邀请人id
  "courseId": 0,  //课程id
  "floatStageFirBar": 0,  // 初级浮动销售额
  "floatStageFirPercentage": 0, // 初级浮动比例
  "floatStageSecBar": 0,   // 高级浮动销售额
  "floatStageSecPercentage": 0, // 高级浮动比例
  "percentage": 0,  // 基础提成比例
}
 */
export const createContract = (data) => fetch({
  url: '/contract/v1',
  method: "post",
  data: data,
});

/**
 * 根据申请组织和合同状态查询合同列表{status: PENDING(发出，未签约)/CONFIRM(发出，已签约)}主动邀请
 */
export const getApplyOrgId = (status, pageNumber) => fetch({
  url: '/contract/v1/applyOrgId',
  method: "get",
  data: { "status": status, pageNumber: pageNumber, pageSize },
});

/**
 * 根据确认合同组织和合同状态查询合同列表{status: PENDING(发出，未签约)/CONFIRM(发出，已签约)}被邀请
 */
export const getConfirmOrgId = (status, pageNumber) => fetch({
  url: '/contract/v1/confirmOrgId',
  method: "get",
  data: { "status": status, pageNumber: pageNumber, pageSize },
});

/**
 * 根据企业查看合同
 */
export const getAllOrg = (pageNumber, name) => fetch({
  url: '/contract/v1/all',
  method: "get",
  data: { pageNumber: pageNumber, pageSize, searchOrgName: name },
});

/**
 * 签署某一份合同
 * params: {stauts: ERROR,          //状态
    PENDING,        // 待确认
    CONFIRM,        //确认
    REJECTED,       //拒绝
    WITHDRAW;       //撤回}
 */
export const handleContract = (id, stauts) => fetch({
  url: '/contract/v1/' + id + '/status',
  method: "put",
  data: JSON.stringify({ "status": stauts }),
});

/**
 * 修改某一份合同比例
 */
export const changeContract = (id, percentage) => fetch({
  url: '/contract/v1/' + id + '/setPercentage',
  method: "put",
  data: JSON.stringify({ "percentage": percentage }),
});

/**
 * 修改某一份合同
 * params: {
  "conConfirmerId": 0,
  "courseId": 0,
  "floatStageFirBar": 0,
  "floatStageFirPercentage": 0,
  "floatStageSecBar": 0,
  "floatStageSecPercentage": 0,
  "pageNumber": 0,
  "pageSize": 0,
  "percentage": 0,
  "status": "ERROR"
}
 */
export const updateContract = (id, data) => fetch({
  url: '/contract/v1/' + id,
  method: "put",
  data: data,
});

// ------------------合同管理------------------

// ---------------官方模板---------------

/**
 * 获取所有的官方模板{
 * "pageNumber": 1, "pageSize": 20,"status": [0: 官方模板] [1: 人工翻译] [2: 人工翻译已发布]
 * }
 */
export const getTemplate = (data) => fetch({
  url: '/template/v1',
  method: "get",
  data: data,
});

/**
 * 搜索官方模板{
 * "pageNumber": 1, "pageSize": 20,"status": [0: 官方模板] [1: 人工翻译] [2: 人工翻译已发布], searchName: ''
 * }
 */
export const searchTemplate = (data) => fetch({
  url: '/template/v1',
  method: "get",
  data: data,
});

/**
 * 获取所有的人工翻译{
 * "pageNumber": 1, "pageSize": 20,"status": [0: 官方模板] [1: 人工翻译] [2: 人工翻译已发布]
 * }
 */
export const getTranslate = (data) => fetch({
  url: '/translate/v1',
  method: "get",
  data: data,
});

/**
 * 获取所有的人工翻译{
 * "pageNumber": 1, "pageSize": 20,"status": [0: 官方模板] [1: 人工翻译] [2: 人工翻译已发布], searchName: ''
 * }
 */
export const searchTranslate = (data) => fetch({
  url: '/translate/v1',
  method: "get",
  data: data,
});

/**
 * 获取单个的官方模板{id}
 */
export const getOneTemplate = (id) => fetch({
  url: '/template/v1/' + id,
  method: "get",
  data: {},
});

/**
 * 创建一个官方模板
 * params: {
 * "status": [0: 官方模板] [1: 人工翻译] [2: 人工翻译已发布]
 * }
 */
export const createOneTemplate = (data) => fetch({
  url: '/template/v1',
  method: "post",
  data: data,
});

/**
 * 发布一个官方模板
 */
export const releaseOneTemplate = (id) => fetch({
  url: '/template/v1/' + id,
  method: "post",
  data: {},
});

/**
 * 修改单个的官方模板{id}
 */
export const updateOneTemplate = (id, data) => fetch({
  url: '/template/v1/' + id,
  method: "put",
  data: JSON.stringify(data),
});

/**
 * 删除单个官方模板{id}
 */
export const removeTemplate = (id) => fetch({
  url: '/template/v1/' + id,
  method: "delete",
  data: {},
});

/**
 * 将人工翻译发送给用户
 */
export const sendTranslate2User = (id, phones) => fetch({
  url: '/translate/v1/' + id + '/send',
  method: "post",
  data: { phones: phones },
});
// ---------------官方模板---------------





